import { createParamDecorator, ExecutionContext } from '@nestjs/common';
import * as requestIp from 'request-ip';

export const IpAddress = createParamDecorator((data, execution: ExecutionContext) => {
  const req = execution.getArgByIndex(0);
  if (req.clientIp) return req.clientIp;
  return requestIp.getClientIp(req);
});
